import org.jooq.Record;
import org.jooq.Result;
import org.jooq.SQLDialect;
import org.jooq.UpdateQuery;
import org.jooq.impl.Factory;
import org.junit.Test;

import com.DBObjects.dbo.Tables;
import com.DBObjects.dbo.tables.SysUsers;
import com.DBObjects.dbo.tables.records.SysUsersRecord;

import utl.mofen.intf.IDBOperator;
import utl.mofen.script.ScriptObjectFactory;
import utl.mofen.utils.GUID;

public class JOOQTester {
	@Test
	public void loginTester() throws Exception {
		IDBOperator dbOpera = ScriptObjectFactory.getDBOperator("yh_main");
		Factory create = new Factory(dbOpera.getConnection(),
				SQLDialect.SQLSERVER);	
		

//		Result<Record> result = create
//				.select()
//				.from(SysUsers.SYS_USERS)
//				.where(SysUsers.SYS_USERS.FKEY
//						.equal("CEDC8470-F480-4927-8D58-8D0A1A1C9E0F")).fetch();
		
		//SysUsersRecord r = new SysUsersRecord();
		
		//添加
		SysUsersRecord r = create.newRecord(SysUsers.SYS_USERS);
		r.setFkey(GUID.createGUID());
		r.setFcode("000000");
		r.store();
		
		//删除
		create.delete(SysUsers.SYS_USERS).where(SysUsers.SYS_USERS.FCODE.equal("000000"));

			
//		SysUsersRecord r = (SysUsersRecord) result.get(0);
//		System.out.println("FCode:" + r.getFcode());
//		System.out.println("FName:" + r.getFname());
//		r.setFname("张三");
//		r.store();
		
		//create.batchStore(r).execute();


		// UpdateQuery<SysUsersRecord> up =
		// create.updateQuery(SysUsers.SYS_USERS);
		// up.addValue(SysUsers.SYS_USERS.FNAME, "吴杏珍_YWB05");
		// up.setRecord(r);
		// up.execute();
		
		
		// System.out.println(up.getSQL(true));

		// create.updateQuery(SysUsers.SYS_USERS).setRecord(r);
		// create.batchStore(r);

	}
}
